import config from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock'

const { code } = config

const timeout = 1000

const mockUsers = [
  {
    id: '0000',
    username: 'admin',
    password: 'admin',
    role: 'admin',
    roleId: '1',
    permissions: ['*.*.*']
  }
]

const mockProperties = [
  {
    id: '0000',
    name: '顶级属性',
    parentId: null,
    childIds: ['0001', '0002', '0003'],
    valuesType: null,
    comments: ['顶级属性', '测试属性'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0001',
    name: '姓名',
    parentId: '0000',
    childIds: ['0001', '0002'],
    valuesType: 'String',
    comments: ['姓名', '通用属性'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0002',
    name: '年龄',
    parentId: '0000',
    childIds: [],
    valuesType: 'Integer',
    comments: ['整数', '年龄'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0003',
    name: '性别',
    parentId: '0000',
    childIds: [],
    valuesType: 'String',
    comments: ['男', '女'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  }
]

const mockConcepts = [
  {
    id: '0000',
    name: '顶级概念',
    parentId: null,
    childIds: ['0001'],
    propertyIds: [mockProperties[1].id],
    comments: ['顶级概念'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0001',
    name: '动物',
    parentId: null,
    childIds: ['0002', '0003'],
    propertyIds: [mockProperties[2].id, mockProperties[3].id],
    comments: ['顶级概念'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0002',
    name: '人',
    parentId: '0001',
    childIds: [],
    propertyIds: [],
    comments: ['人'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0003',
    name: '猴',
    parentId: '0001',
    childIds: [],
    propertyIds: [],
    comments: ['猿猴'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  }
]

const mockRelations = [
  {
    id: '0000',
    name: '顶级关系',
    parentId: null,
    childIds: ['0001', '0002'],
    sourceConceptId: null,
    targetConceptId: null,
    propertyId: [],
    comments: ['顶级关系'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0001',
    name: '血缘关系',
    parentId: '0000',
    childIds: ['0004', '0005'],
    sourceConceptId: null,
    targetConceptId: null,
    propertyId: [],
    comments: ['血缘关系'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0002',
    name: '社会关系',
    parentId: '0000',
    childIds: ['0003'],
    sourceConceptId: null,
    targetConceptId: null,
    propertyId: [],
    comments: ['社会关系'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0003',
    name: '配偶',
    parentId: '0002',
    childIds: [],
    sourceConceptId: mockConcepts[0].id,
    targetConceptId: mockConcepts[2].id,
    propertyId: [],
    comments: ['夫妻'],
    creatorId: mockUsers[0],
    createDate: new Date(),
    updatorId: mockUsers[0],
    updateDate: new Date()
  },
  {
    id: '0004',
    name: '母亲',
    parentId: '0001',
    childIds: [],
    sourceConceptId: mockConcepts[0].id,
    targetConceptId: mockConcepts[1].id,
    propertyId: [],
    comments: ['母子关系'],
    creatorId: mockUsers[0].id,
    createDate: new Date(),
    updatorId: mockUsers[0].id,
    updateDate: new Date()
  },
  {
    id: '0005',
    name: '父亲',
    parentId: '0001',
    childIds: [],
    sourceConceptId: mockConcepts[1].id,
    targetConceptId: mockConcepts[2].id,
    propertyId: [],
    comments: ['父子关系'],
    creatorId: mockUsers[0],
    createDate: new Date(),
    updatorId: mockUsers[0],
    updateDate: new Date()
  }
]

export default [
  // 本体属性查询
  {
    url: '/graph/ontology/property',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: code,
        data: mockProperties
      }
    }
  },
  // 本体概念查询
  {
    url: '/graph/ontology/concept',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: code,
        data: mockConcepts
      }
    }
  },

  // 本体关系查询
  {
    url: '/graph/ontology/relation',
    method: 'get',
    timeout,
    response: () => {
      return {
        code: code,
        data: mockRelations
      }
    }
  }
] as MockMethod[]
